#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e5+10;
const int mod = 1e9+7;

int x,y,p[N],pnum;
bool v[N];
ll ans;

ll qp(ll x,int t){ll res=1;for(;t;t>>=1,x=x*x%mod)if(t&1)res=res*x%mod;return res;}

void shai(int n){
	for(int i = 2;i <= n;i++){
		if(!v[i]) p[++pnum] = i;
		for(int j = 1;j <= pnum && p[j] * i <= n;j++){
			v[p[j] * i] = 1; if(i % p[j] == 0) break;
		}
	}
}

int mu(int x){
	int res = 1;
	for(int i = 1;i <= pnum && p[i] * p[i] <= x;i++){
		if(x % p[i]) continue; int cc = 0;
		while(x % p[i] == 0) cc++,x /= p[i];
		if(cc > 1) return 0; res = -res;
	}
	if(x > 1) return -res;return res;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	x = in,y = in; if(y % x) return puts("0"),0;
	shai(sqrt(y / x) + 10); y /= x;
	for(int i = 1;i * i <= y;i++){
		if(y % i == 0){
			ans = (ans + 1ll * mu(y / i) * qp(2,i-1) % mod) % mod;
			if(i * i != y) ans = (ans + 1ll * mu(i) * qp(2,(y / i) - 1) % mod) % mod;
		}
	}ans = (ans + mod) % mod;
	printf("%lld\n",ans);
	return 0;
}

